import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:light_compressor_ohos/compression_result.dart';
import 'package:light_compressor_ohos/light_compressor_ohos.dart';
import 'package:light_compressor_ohos/light_compressor_ohos_method_channel.dart';
import 'package:light_compressor_ohos/light_compressor_ohos_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

class MockLightCompressorOhosPlatform
    with MockPlatformInterfaceMixin
    implements LightCompressorOhosPlatform {

  @override
  Future<String?> getPlatformVersion() => Future.value('42');

  @override
  Future<bool?> cancelCompression() async {
    return true;
  }

  @override
  Future<double> getFileSize(String filePath) async {
    return 100.0;
  }

  @override
  Stream<double> getUpdateStream() {
    return Stream.value(100.0);
  }

  @override
  Future<String?> selectVideo() async {
    return "videoPath";
  }

  @override
  Future<Result> startCompression({required String path, required VideoQuality videoQuality}) async{
    return const OnSuccess("success");
  }
}

void main() {

  test('cancelCompression', () async {
    MockLightCompressorOhosPlatform fakePlatform = MockLightCompressorOhosPlatform();
    LightCompressorOhosPlatform.instance = fakePlatform;
    LightCompressorOhos lightCompressorOhosPlugin = LightCompressorOhos();
    expect(await lightCompressorOhosPlugin.cancelCompression(), true);
  });

  test('getFileSize', () async {
    MockLightCompressorOhosPlatform fakePlatform = MockLightCompressorOhosPlatform();
    LightCompressorOhosPlatform.instance = fakePlatform;
    LightCompressorOhos lightCompressorOhosPlugin = LightCompressorOhos();
    expect(await lightCompressorOhosPlugin.getFileSize("filePath"), 100.0);
  });

  test('selectVideo', () async {
    LightCompressorOhos lightCompressorOhosPlugin = LightCompressorOhos();
    MockLightCompressorOhosPlatform fakePlatform = MockLightCompressorOhosPlatform();
    LightCompressorOhosPlatform.instance = fakePlatform;
    expect(await lightCompressorOhosPlugin.selectVideo(), "videoPath");
  });

  test('startCompression', () async {
    LightCompressorOhos lightCompressorOhosPlugin = LightCompressorOhos();
    MockLightCompressorOhosPlatform fakePlatform = MockLightCompressorOhosPlatform();
    LightCompressorOhosPlatform.instance = fakePlatform;
    expect(await lightCompressorOhosPlugin.startCompression(path: "filePath",videoQuality: VideoQuality.medium), const OnSuccess("success"));
  });
}
